home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d11 / evnansi.arc / EVNANSIF.ASM < prev    next >
Assembly Source File  |  1990-07-03  |  19KB  |  698 lines

  1.     page    66, 132
  2. ;----- evnansif.asm ---------------------------------------------
  3. ; The ANSI control subroutines.
  4. ; (C) 1986 Daniel Kegel, Pasadena, CA
  5. ; May be distributed for educational and personal use only
  6. ; Each routine is called with the following register usage:
  7. ;  AX = max(1, value of first parameter)
  8. ;  Z flag is set if first parameter is zero.
  9. ;  CX = number of paramters
  10. ;  SI = offset of second parameter from CS
  11. ;  DS = CS
  12. ;  ES:DI points to the current location on the memory-mapped screen.
  13. ;  DX is number of characters remaining on the current screen line.
  14. ; The control routine is free to trash AX, BX, CX, SI, and DS.
  15. ; It must preserve ES, and can alter DX and DI if it wants to move the
  16. ; cursor.
  17. ;
  18. ; Revisions:
  19. ;  19 Aug 85: Fixed horrible bug in insert/delete line.
  20. ;  26 Aug 85: Fixed simple limit-to-one-too-few-lines bug in ins/del line;
  21. ;  anyway, it inserts 24 lines when on line 2 now.  Whether it's fixed...
  22. ;  4 Sept 85: Fixed bug created on 26 Aug 85; when limiting ins/del line
  23. ;  count, we are clearing, not scrolling; fixed BIOS call to reflect this.
  24. ;  30 Jan 86: Added EGA cursor patch
  25. ;  31 Jan 86: Disabled insert/delete char in graphics modes
  26. ;          Implemented keyboard redefinition reset
  27. ;  1 Feb 86: added video_mode and max_x test after mode set
  28. ;----------------------------------------------------------------
  29.  
  30.     include evnansid.asm
  31.  
  32.     ; To evnansip.asm
  33.     public    ansi_fn_table
  34.  
  35.     ; From evnansi.asm
  36.     extrn    port_6845:word
  37.     extrn    cur_coords:word, saved_coords:word
  38.     extrn    cur_x:byte, max_x:byte
  39.     extrn    cur_y:byte, max_y:byte
  40.     extrn    cur_attrib:byte, wrap_flag:byte
  41.     extrn    xy_to_regs:near
  42.     extrn    get_blank_attrib:near
  43.     extrn    xlate_tab_ptr:word
  44.     extrn    cpr_esc:byte, cprseq:word
  45.     extrn    video_mode:byte
  46.     extrn    lookup:near
  47.     extrn    in_g_mode:near
  48.  
  49.     ; from evnansip.asm
  50.     extrn    param_buffer:word    ; used in keyboard programming
  51.     extrn    param_end:word
  52.     extrn    redef_end:word
  53.  
  54. keybuf    struc                ; used in making cpr sequence
  55. len    dw    ?
  56. adr    dw    ?
  57. keybuf    ends
  58.  
  59.  
  60. ABS40    segment at 40h
  61.     org    1ah
  62. buffer_head    dw    ?    ; Used in 'flush input buffer' dos call.
  63. buffer_tail    dw    ?
  64.  
  65.     org    49h
  66. crt_mode    db    ?
  67. crt_cols    dw    ?
  68. crt_len     dw    ?
  69. crt_start    dw    ?
  70. cursor_posn    dw    8 dup (?)
  71. cursor_mode    dw    ?
  72. active_page    db    ?
  73. addr_6845    dw    ?
  74. crt_mode_set    db    ?
  75. crt_palette    db    ?
  76.  
  77. ;GL:11-29-88 -----------------------------------------------------------
  78. ; EGA/VGA information
  79.     org    84h
  80. crt_rows    db    ?
  81. fontsize    dw    ?
  82. egainfo        db    ?
  83. egaswitches    db    ?
  84. vgainfo        db    ?
  85. dccindex    db    ?
  86. ;GL:11-29-88 -----------------------------------------------------------
  87. ABS40    ends
  88.  
  89. code    segment byte public 'CODE'
  90.     assume cs:code, ds:code
  91.  
  92. ;----- byteout ---------------------------------------------------
  93. ; Converts al to a decimal ASCII string (in 0..99),
  94. ; stores it at ES:DI++.  Returns DI pointing at byte after last digit.
  95. ; Destroys DL.
  96.  
  97. byteout proc    near
  98.     aam
  99.     add    ax, 3030h
  100.     xchg    ah, al
  101.     stosb
  102.     xchg    ah, al
  103.     stosb
  104.     ret
  105. byteout endp
  106.  
  107. ;----- ansi_fn_table -----------------------------------
  108. ; Table of offsets of terminal control subroutines in order of
  109. ; the character that invokes them, @..Z, a..z.    Exactly 53 entries.
  110. ; All the subroutines are defined below in this module.
  111. ansi_fn_table    label    word
  112.     dw    ic,  cup, cdn, cfw, cbk     ; @, A, B, C, D
  113.     dw    nul, nul, nul, hvp, nul     ; E, F, G, H, I
  114.     dw    eid, eil, il,  d_l, nul     ; J, K, L, M, N
  115.     dw    nul, dc,  nul, nul, nul     ; O, P, Q, R, S
  116.     dw    nul, nul, nul, nul, nul     ; T, U, V, W, X
  117.     dw    nul, nul            ; Y, Z
  118.     dw    nul, nul, nul, nul, nul     ; a, b, c, d, e
  119.     dw    hvp, nul, sm,  nul, nul     ; f, g, h, i, j
  120.     dw    nul, rm,  sgr, dsr, nul     ; k, l, m, n, o
  121.     dw    key, nul, nul, scp, nul     ; p, q, r, s, t
  122.     dw    rcp, nul, nul, nul, xoc     ; u, v, w, x, y
  123.     dw    nul                ; z
  124.  
  125. ansi_functions    proc    near        ; set return type to NEAR
  126.  
  127. ;----- nul ---------------------------------------------
  128. ; No-action ansi sequence; called when unknown command given.
  129. nul:    ret
  130.  
  131. ;----- Cursor Motion -----------------------------------------------
  132.  
  133. ;-- cursor to y,x
  134. hvp:    or    al, al        ; First parameter is desired Y coordinate.
  135.     jz    hvp_yok
  136.     dec    ax        ; Convert to zero-based coordinates.
  137. hvp_yok:mov    cur_y, al
  138.     ; Get second parameter, if it is there, and set X with it.
  139.     xor    ax, ax
  140.     cmp    cx, 2        ; was there a second parameter?
  141.     jb    hvp_xok
  142.     lodsb            ; yes.
  143.     or    al, al
  144.     jz    hvp_xok
  145.     dec    ax        ; convert to zero-based coordinates.
  146. hvp_xok:mov    cur_x, al
  147.  
  148.     ; Clip to maximum coordinates.
  149. hvp_set:
  150.     mov    ax, cur_coords        ; al = x, ah = y
  151.     cmp    al, max_x
  152.     jbe    hvp_sxok
  153.         mov    al, max_x
  154.         mov    cur_x, al
  155. hvp_sxok:
  156.     cmp    ah, max_y
  157.     jbe    hvp_syok
  158.         mov    al, max_y
  159.         mov    cur_y, al
  160. hvp_syok:
  161.     ; Set values of DX and DI accordingly.
  162.     call    xy_to_regs
  163.     ret
  164.  
  165. ;-- cursor forward --
  166. cfw:    add    cur_x, al
  167.     jmp    hvp_set
  168.  
  169. ;-- cursor back -----
  170. cbk:    sub    cur_x, al
  171.     jae    cbk_ok
  172.         mov    cur_x, 0
  173. cbk_ok: jmp    hvp_set
  174.  
  175. ;-- cursor down -----
  176. cdn:    add    cur_y, al
  177.     jmp    hvp_set
  178.  
  179. ;-- cursor up -------
  180. cup:    sub    cur_y, al
  181.     jae    cup_ok
  182.         mov    cur_y, 0
  183. cup_ok: jmp    hvp_set
  184.  
  185. ;-- save cursor position --------------------------------------
  186. scp:    mov    ax, cur_coords
  187.     mov    saved_coords, ax
  188.     ret
  189.  
  190. ;-- restore cursor position -----------------------------------
  191. rcp:    mov    ax, saved_coords
  192.     mov    cur_coords, ax
  193.     jmp    hvp_set     ; Clip in case we have switched video modes.
  194.  
  195. ;-- set graphics rendition ------------------------------------
  196. ; Modifies the color in which new characters are written.
  197.  
  198. sgr:    dec    si        ; get back pointer to first parameter
  199.     or    cx, cx        ; Did he give any parameters?
  200.     jnz    sgr_loop
  201.         mov    byte ptr [si], 0    ; no parameters, so fake
  202.         inc    cx            ; one with the default value.
  203.     ; For each parameter
  204. sgr_loop:
  205.         lodsb                ; al = next parameter
  206.         ; Search color table
  207.         push    cx
  208.         mov    cx, colors
  209.         mov    bx, offset color_table-3
  210. sgr_search:
  211.             add    bx, 3
  212.             cmp    al, byte ptr [bx]
  213.             loopnz    sgr_search    ; until match found or done
  214.         jnz    sgr_loopx
  215.  
  216.         ; If parameter named a known color, set the current
  217.         ; color variable.
  218.         mov    ax, [bx+1]
  219.         and    cur_attrib, al
  220.         or    cur_attrib, ah
  221. sgr_loopx:
  222.         pop    cx
  223.         loop    sgr_loop        ; until no more parameters.
  224.     ret
  225.  
  226. ;-- erase in line ----------------------------------------
  227. ; Uses BIOS to scroll away a one-line rectangle
  228. eil:    push    dx
  229.     mov    cx, cur_coords
  230.     mov    dh, ch
  231.     jmp    short scrollem
  232.  
  233. ;-- erase in display -------------------------------------
  234. ; Uses BIOS to scroll away all of display
  235. eid:    cmp    al, 2
  236.     jnz    eid_ignore    ; param must be two
  237.     if    cls_homes_too
  238.         mov    cur_coords, 0
  239.         call    xy_to_regs
  240.     endif
  241.     push    dx
  242.     xor    cx, cx
  243.     mov    dh, max_y
  244. scrollem:
  245.     call    get_blank_attrib
  246.     mov    bh, ah
  247.     mov    dl, max_x
  248.     mov    ax, 600h
  249.     int    10h
  250.     pop    dx
  251. eid_ignore:
  252.     ret
  253.  
  254. ;-- device status report --------------------------------
  255. ; Stuffs an escape, a left bracket, current Y, semicolon, current X,
  256. ; a capital R, and a carriage return into input stream.
  257. ; The coordinates are 1 to 3 decimal digits each.
  258.  
  259. dsr:    push    di
  260.     push    dx
  261.     push    es
  262.     mov    ax, cs
  263.     mov    es, ax
  264.     std            ; Store string in reversed order for fun
  265.     mov    di, offset cpr_esc - 2
  266.     mov    al, cur_y
  267.     inc    al        ; convert to one-based coords
  268.     call    byteout     ; row
  269.     mov    al, ';'         ; ;
  270.     stosb
  271.     mov    al, cur_x
  272.     inc    al        ; convert to one-based coords
  273.     call    byteout     ; column
  274.     mov    al, 'R'         ; R ANSI function 'Cursor Position Report'
  275.     stosb
  276.     mov    al, 13
  277.     mov    word ptr cprseq.adr, di ; save pointer to last char in string
  278.     stosb                ; send a carriage return, too
  279.     mov    ax, offset cpr_esc
  280.     sub    ax, di            ; ax is # of characters in string
  281.     mov    word ptr cprseq.len, ax ; pass info to the getchar routine
  282.     cld
  283.     pop    es
  284.     pop    dx
  285.     pop    di
  286.     ret
  287.  
  288. ;-- keyboard reassignment -------------------------------
  289. ; Key reassignment buffer is between param_end and redef_end+2, exclusive.
  290. ; When it shrinks or grows, param_end is moved.
  291. ; Format of an entry is as follows:
  292. ;   highest address -> length:word (may be 0)
  293. ;               key to replace:word     (either hi or low byte is zero)
  294. ;               .
  295. ;               .    new key value, "length" bytes long
  296. ;               .
  297. ;   lowest address  -> next entry, or free space.
  298. ; If no arguments are given, keyboard is reset to default condition.
  299. ; Otherwise, first parameter (or first two, if first is zero) defines
  300. ; the key whose value is to be changed, and the following parameters
  301. ; define the key's new, possibly zero-length, value.
  302.  
  303. key:
  304.     ; Is this a reset?
  305.     or    cx, cx
  306.     jz    key_init
  307.     ; Get the first (or first two) parameters
  308.     cld
  309.     dec    si    ; point to first param
  310.     dec    cx    ; Assume it's a fn key, get two params
  311.     dec    cx
  312.     lodsw
  313.     or    al, al    ; Is it a function key?
  314.     jz    key_fnkey
  315.         ; It's not a function key- put second param back
  316.         inc    cx
  317.         dec    si
  318. key_fnkey:
  319.     ; Key to redefine now in AX.  If it's already redefined,
  320.     ; lookup will set Z, point SI to redef string, set CX to its length.
  321.     push    di
  322.     push    es
  323.     push    cx
  324.     push    si
  325.  
  326.     std            ; moving up, must move from top down
  327.     push    ds
  328.     pop    es        ; string move must have ES=DS
  329.     call    lookup        ; rets Z if redefined...
  330.     jnz    key_newkey
  331.     ; It's already defined.  Erase its old definition- i.e., move
  332.     ; region param_end+1..SI-1 upwards CX+4 bytes, add CX+4 to param_end.
  333.     add    cx, 4
  334.     mov    bp, param_end    ; save old value in bp...
  335.     add    param_end, cx
  336.     dec    si        ; start at (SI-1)
  337.     mov    di, si
  338.     add    di, cx        ; move to (start + CX+4)
  339.     mov    cx, si
  340.     sub    cx, bp        ; length of region old_param_end+1..start
  341.     rep    movsb
  342. key_newkey:
  343.     ; Key not redefined.  See if there's enough room to redefine it.
  344.     pop    si        ; get back pointer to redef string
  345.     pop    cx        ; get back number of bytes in redef string
  346.     mov    di, param_end    ; hi byte of new redef record, hi byte of len
  347.     sub    di, 4        ; hi byte of new data field
  348.     mov    bx, di
  349.     sub    bx, cx        ; hi byte of remaining buffer space
  350.     sub    bx, 16        ; better be at least 16 bytes room
  351.     cmp    bx, param_buffer
  352.     jb    key_popem    ; nope- forget it.
  353.     ; Nothing in the way now!
  354.     mov    [di+3], cx    ; save length field
  355.     mov    [di+1], ax    ; save name field
  356.     jcxz    key_nullstring
  357. key_saveloop:            ; save data field
  358.     movsb
  359.     add    si, 2        ; input string ascending, output descending
  360.     loop    key_saveloop
  361. key_nullstring:
  362.     mov    param_end, di    ; save adr of new hi byte of free area
  363. key_popem:
  364.     pop    es
  365.     pop    di
  366.  
  367. key_exit:
  368.     cld
  369.     ret
  370.  
  371. key_init:
  372.     ; Build the default redefinition table:
  373.     ;    control-printscreen -> control-P
  374.     push    es
  375.     push    ds
  376.     pop    es
  377.     std
  378.     mov    di, redef_end
  379.     mov    ax, 1
  380.     stosw
  381.     mov    ax, 7200h    ; control-printscreen
  382.     stosw
  383.     mov    al, 16        ; control P
  384.     stosb
  385.     mov    param_end, di    ; save new bottom of redef table
  386.     pop    es
  387.     jmp    key_exit
  388.  
  389. ;---- Delete/Insert Lines -------------------------------
  390. ; AL is number of lines to delete/insert.
  391. ; Preserves DX, DI; does not move cursor.
  392.  
  393. d_l:    ; Delete lines.
  394.     mov    ah, 6            ; BIOS: scroll up
  395.     jmp    short il_open
  396.  
  397. il:    ; Insert lines.
  398.     mov    ah, 7            ; BIOS: scroll down
  399.  
  400. il_open:
  401.     ; Whether inserting or deleting, limit him to (max_y - cur_y) lines;
  402.     ; if above that, we're just clearing; set AL=0 so BIOS doesn't burp.
  403.     mov    bh, max_y
  404.     sub    bh, cur_y
  405.     cmp    al, bh
  406.     jbe    il_ok            ; DRK 9/4...
  407.         mov    al, 0        ; he tried to move too far
  408. il_ok:
  409.     push    ax
  410.     call    get_blank_attrib
  411.     mov    bh, ah            ; color to use on new blank areas
  412.     pop    ax            ; AL is number of lines to scroll.
  413.  
  414.     mov    cl, 0            ; upper-left-x of data to scroll
  415.     mov    ch, cur_y        ; upper-left-y of data to scroll
  416.     push    dx
  417.     mov    dl, max_x        ; lower-rite-x
  418.     mov    dh, max_y        ; lower-rite-y (zero based)
  419.     int    10h            ; call BIOS to scroll a rectangle.
  420.     pop    dx
  421.     ret                ; done.
  422.  
  423. ;-- Insert / Delete Characters ----------------------------
  424. ; AL is number of characters to insert or delete.
  425. ; Preserves DX, DI; does not move cursor.
  426.  
  427. ic:    mov    ch, 1            ; 1 => swap dest & source below
  428.     jmp    short dc_ch
  429.  
  430. dc:    mov    ch, 0
  431.  
  432. dc_ch:
  433.     call    in_g_mode
  434.     jnc    dc_ret            ; | if in graphics mode, ignore.
  435.  
  436.     ; AL = number of chars to ins or del (guarenteed nonzero).
  437.     ; Limit him to # of chars left on line.
  438.     cmp    al, dl
  439.     jbe    dc_cok
  440.         mov    al, dl
  441. dc_cok:
  442.     push    di            ; DI is current address of cursor
  443.     xchg    ax, cx            ; CX gets # of chars to ins/del
  444.     mov    bp, cx            ; BP gets # of columns to clear.
  445.  
  446.     ; Set up source = destination + cx*2, count = dx - cx
  447.     mov    ch, 0            ; make it a word
  448.     mov    si, di
  449.     add    si, cx
  450.     add    si, cx
  451.     neg    cl
  452.     add    cl, dl
  453.     mov    ch, 0            ; CX = # of words to transfer
  454.     cld                ; REP increments si & di
  455.  
  456.     ; If this is an insert, then flip transfer around in both ways.
  457.     test    ah, 1
  458.     jz    dc_noswap
  459.         xchg    di, si        ; source <-> dest
  460.         std            ; up <-> down
  461.         mov    ax, cx        ; make move over same range
  462.         dec    ax
  463.         add    ax, ax        ; AX=dist from 1st to last byte.
  464.         add    di, ax        ; Start transfer at high end of block
  465.         add    si, ax        ;  instead of low end.
  466. dc_noswap:
  467.     ; Move those characters.
  468.     push    es
  469.     pop    ds
  470.     rep    movsw
  471.     mov    cx, bp
  472.     ; Figure out what color to make the new blanks.
  473.     call    get_blank_attrib
  474.     mov    al, ' '
  475.     ; Blank out vacated region.
  476.     rep    stosw
  477.  
  478.     ; All done.
  479.     cld                ; restore normal REP state and
  480.     pop    di            ;  cursor address.
  481. dc_ret: ret
  482.  
  483.  
  484. ;---- set / reset mode ---------------------------------------
  485. ; Sets graphics/text mode; also sets/resets "no wrap at eol" mode.
  486. sm:    mov    cl, 0ffh    ; set
  487. sm_rs:
  488.     ; Is it "wrap at eol" ?
  489.     cmp    al, 7
  490.     jnz    sm_notwrap
  491.         mov    wrap_flag, cl    ; true = wrap at EOL
  492. ;GL:11-29-88 -----------------------------------------------------------
  493.         jmp    sm_done
  494. ;        jmp    short sm_done
  495. ;GL:11-29-88 -----------------------------------------------------------
  496. sm_notwrap:
  497. ;GL:11-29-88 -----------------------------------------------------------
  498. ; Modify for Everex Extended modes 80h,...
  499.     cmp    al,80h
  500.     jb    Check43and50Line
  501.  
  502.     and    al,7Fh            ; Get out Everex Extended mode
  503.  
  504.     mov    bl,al
  505.     mov    ax,0070h
  506.     int    10h            ; Set Everex Extended mode
  507.  
  508.     mov    ax, 1200h        ; Load new printscreen
  509.     mov    bl, 20h
  510.     int    10h
  511.  
  512. ; Get the real number of rows from BIOS data area
  513.     mov    ax, abs40
  514.     push    ds
  515.     mov    ds, ax
  516.     assume    ds:abs40
  517.  
  518.     mov    al,crt_rows        ; Get number of rows
  519.     pop    ds
  520.     mov    max_y,al
  521.     jmp    short sm_home
  522.  
  523. Check43and50Line:
  524. ;GL:11-29-88 -----------------------------------------------------------
  525.     ; Is it "set highest number of screen lines available"?
  526.     cmp    al, 43
  527.     jnz    sm_video
  528.         ; Only valid for the Enhanced Graphics Adaptor on
  529.         ; a monochrome display or an enhanced color display.
  530.         ; Test presence of EGA by calling BIOS fn 12h.10h.
  531.         mov    ah, 12h
  532.         mov    bx, 0ff10h
  533.         int    10h            ; bh=0-1, bl=0-3 if EGA
  534.         test    bx, 0FEFCH
  535.         jnz    sm_done         ; sorry, charlie
  536. ;        mov    port_6845, 3d4h
  537. ;        mov    al, video_mode
  538. ;        and    al, 7
  539. ;        cmp    al, 7            ; monochrome monitor?
  540. ;        jnz    sm_colormon
  541. ;            mov    byte ptr port_6845, low(3b4h)
  542. ;sm_colormon:
  543.         ; 43 line mode only allowed in text modes, for now.
  544.         call    in_g_mode
  545.         jnc    sm_done
  546.  
  547.         mov    ah, 0            ; "Set video mode"
  548.         mov    al, video_mode        ; Re-init current mode
  549.         int    10h
  550.  
  551.         mov    ax,1112h        ; Load 8x8 font
  552.         mov    bl,0            ; (instead of 8x14)
  553.         int    10h
  554.  
  555.         mov    ax, 1200h        ; Load new printscreen
  556.         mov    bl, 20h
  557.         int    10h
  558.  
  559.         mov    ah,1
  560. ;GL:11-29-88 -----------------------------------------------------------
  561.         mov    cx,0607h        ; (Load cursor scan lines)
  562. ;        mov    cx,0707h        ; (Load cursor scan lines)
  563. ;GL:11-29-88 -----------------------------------------------------------
  564.         int    10h
  565. ;GL:11-29-88 -----------------------------------------------------------
  566. ; Shouldn't need to be done
  567. ;        ; | Patch; this gotten by painful observation of
  568. ;        ; | IBM's professional editor.  I think there's a
  569. ;        ; | documented bug in Video Bios's "load cursor scan line"
  570. ;        ; | call; try looking in latter 1985 PC Tech Journal.
  571. ;        mov    dx, port_6845        ; '6845' command reg
  572. ;        mov    al, 10
  573. ;        out    dx, al
  574. ;        jmp    $+2
  575. ;        inc    dx
  576. ;        mov    al, 7
  577. ;        out    dx, al            ; set cursor start line
  578. ;GL:11-29-88 -----------------------------------------------------------
  579.  
  580. ;GL:11-29-88 -----------------------------------------------------------
  581. ; Get the real number of rows from BIOS data area
  582.     mov    ax, abs40
  583.     push    ds
  584.     mov    ds, ax
  585.     assume    ds:abs40
  586.  
  587.     mov    al,crt_rows        ; Get number of rows
  588.     pop    ds
  589.     mov    max_y,al
  590.     jmp    short sm_home
  591.  
  592. ;        ; Assume that gets us 43 lines.
  593. ;        mov    max_y, 42
  594. ;        jmp    short sm_home
  595. ;GL:11-29-88 -----------------------------------------------------------
  596. sm_video:
  597.     ; It must be a video mode.  Call BIOS.
  598.     mov    ah, 0        ; "set video mode"
  599.     int    10h
  600.     ; Assume that gets us 25 lines.
  601.     mov    max_y, 24
  602. sm_home:
  603.     ; Read the BIOS buffer address/cursor position variables.
  604.     mov    ax, abs40
  605.     push    ds
  606.     mov    ds, ax
  607.     assume    ds:abs40
  608.     ; Find current video mode and screen size.
  609.     mov    ax,word ptr crt_mode    ; al = crt mode; ah = # of columns
  610.     pop    ds
  611.     mov    video_mode, al
  612.     dec    ah            ; ah = max column
  613.     mov    max_x, ah
  614.  
  615.     ; Since cursor may end up in illegal position, it's best to
  616.     ; just go home after switching video modes.
  617.     mov    cur_coords, 0
  618.     call    xy_to_regs
  619. sm_done:
  620.     ret
  621.  
  622. rm:    mov    cl, 0        ; reset
  623.     jmp    sm_rs
  624.  
  625. ;------- Output Character Translation ----------------------
  626. ; A decidedly nonstandard function, possibly useful for editing files
  627. ; intended to be printed by daisywheel printers with strange wheels.
  628. ; (The letter 'y' was chosen to conflict with the VT100 self-test command.)
  629. ; Usage: ESC [ #1;#2 y
  630. ; where #1 is the character to redefine
  631. ;    #2 is the new display value
  632. ; If only ESC [ #1 y is sent, character #1 is reset to its default value.
  633. ; If only ESC [ y is sent, the entire table is reset to the default value.
  634. ; (If only ESC [ #1; y is sent, character #1 is set to zero... sigh.)
  635.  
  636. xoc:    ; Xlate output character
  637.     mov    bx, xlate_tab_ptr
  638.     jcxz    xoc_reset    ; if no parameters, reset table to 1:1
  639.     dec    si        ; point to first parameter
  640.     lodsw            ; first parameter to AL, second to AH
  641.     dec    cx        ; is parameter count 1?
  642.     jnz    xoc_bothparams
  643.         mov    ah, al    ; if only one param, reset that char.
  644. xoc_bothparams:
  645.     add    bl, al
  646.     adc    bh, 0        ; bx points to entry for char AL
  647.     mov    byte ptr [bx], ah    ; change that entry
  648. xoc_done:
  649.     ret
  650.  
  651. xoc_reset:
  652.     ; Fill table with default values- i.e. 0, 1, 2, ... 255.
  653.     xor    ax, ax
  654. xoc_loop:
  655.     mov    byte ptr [bx], al
  656.     inc    bx
  657.     inc    al
  658.     jnz    xoc_loop
  659.     jmp    xoc_done
  660.  
  661. ansi_functions    endp    ; end dummy procedure block
  662.  
  663.  
  664.  
  665. ;-------- Color table -----------------------------------------
  666. ; Used in "set graphics rendition"
  667. colors    equ    22            ; number of colors in table
  668. color_table:
  669.     db    0, 000h,07h        ; all attribs off; normal.
  670.     db    1, 0ffh,08h        ; bold
  671.     db    4, 0f8h,01h        ; underline
  672.     db    5, 0ffh,80h        ; blink
  673.     db    7, 0f8h,70h        ; reverse
  674.     db    8, 088h,00h        ; invisible
  675.  
  676.     db    30,0f8h,00h        ; black foreground
  677.     db    31,0f8h,04h        ; red
  678.     db    32,0f8h,02h        ; green
  679.     db    33,0f8h,06h        ; yellow
  680.     db    34,0f8h,01h        ; blue
  681.     db    35,0f8h,05h        ; magenta
  682.     db    36,0f8h,03h        ; cyan
  683.     db    37,0f8h,07h        ; white
  684.  
  685.     db    40,08fh,00h        ; black background
  686.     db    41,08fh,40h        ; red
  687.     db    42,08fh,20h        ; green
  688.     db    43,08fh,60h        ; yellow
  689.     db    44,08fh,10h        ; blue
  690.     db    45,08fh,50h        ; magenta
  691.     db    46,08fh,30h        ; cyan
  692.     db    47,08fh,70h        ; white
  693.  
  694.  
  695. code    ends
  696.     end                ; of evnansif.asm
  697.  
  698.